package com.bank.controller;

import com.alibaba.fastjson.JSON;
import com.bank.model.Assets;
import com.bank.model.Card;
import com.bank.service.InfoService;
import com.bank.service.VerifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class CardController {
    @Autowired
    InfoService infoService;

    @Autowired
    VerifyService verifyService;

    @RequestMapping(value = "/myCards",method = RequestMethod.GET)
    public String getCards(@RequestParam("uid")String uid ) {
        Map<String,Object> ret = new HashMap<>();
        List<Card> list = infoService.getAllCardsList(uid);
        ret.put("data",list);
        return JSON.toJSONString(ret);
    }

    @RequestMapping(value = "/applyNewCard",method = RequestMethod.POST)
    public String applyCard(@RequestBody Map<String,String> map) {
        return JSON.toJSONString(verifyService.verifyCards(map.get("uid"),Integer.parseInt(map.get("type")),map.get("password")));
    }

}
